package com.yhy.client;

import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.socket.DatagramPacket;
import io.netty.handler.codec.MessageToMessageDecoder;
import io.netty.util.CharsetUtil;

import java.util.List;

/**
 * describe:
 *
 * @author helloworldyu
 * @date 2018/5/8
 */
public class DatagramStringDecoder extends MessageToMessageDecoder<DatagramPacket> {

	@Override
	protected void decode(ChannelHandlerContext ctx, DatagramPacket msg, List<Object> out) throws Exception {
		ByteBuf data = msg.content();
		String s = data.toString(CharsetUtil.UTF_8);
		out.add(s);
	}
}